export const getBookTitle = (val) => {
	let titles = {
		science: '科幻',
		whodunit: '推理',
		workspace: '职场',
		love: '爱情',
		Supernatural: '灵异',
		literature: '文学'
	}
	if (val && titles[val]) return titles[val]
	return false
}

export const backPath = (val) => {
	// 传入的值必须是当前的路由的path
	if (!val) return false
	let routers = val.split('/')
	if (routers.length === 1) return false

	let path1 = {
		articles: '/'
	}
	let path2 = {
		bookinfo: ['/science', '/whodunit', '/workspace', '/love', '/Supernatural', '/literature']
	}
	if (path1[routers[1]]) return path1[routers[1]]
	if (path2[routers[1]]) {
		let paths = path2[routers[1]]
		return '/articles' + paths[routers[2].substr(0, 1) - 1]
	}
	if (routers[1] === 'book') return val.replace('book', 'bookinfo')

	return false
}
